package com.dao;

import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.sql.Statement;
public class UserJdbc {
	  Connection conn;
	  Statement stem;
	  ResultSet rs ;
	  public  void  lianjie (){
		  try {
			Class.forName("com.mysql.cj.jdbc.Driver");
			conn = DriverManager.getConnection("jdbc:mysql://120.76.45.216:3306/buy_ticket","root","root");
		} catch (Exception e) {
			e.printStackTrace();
		} 
	  }
	
	  public ResultSet show(){
          this.lianjie();
          // 向数据库发送sql 语句的
		try {
			  stem = conn.createStatement();
			  rs = stem.executeQuery(" select  * from  admin");
		} catch (SQLException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		}
          return  rs;
	  }
	 
	public  void  close(){
		  try {
			if(conn!=null){
				  conn.close();
			  }

			  if(stem!=null){
				  stem.close();
			  }

			  if(rs!=null){
				  rs.close();
			  }
		} catch (SQLException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		}
	}
}
